home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 7
/
007.d81
/
dos #15
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
196 lines
DOS & DON'ts -- Part 15
{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
by : Alan W. Gardner
This month we will attempt to 'leap'
into the world of RANDOM DISK ACCESS.
First of all, we need to know some-
things about that little magnetic
thing we all call a DISK. We have
probably all heard the parallel of a
disk to a musical record or LP. Both
have concentric circles which contain
DATA. On a disk, these 'circles' are
divided into SECTORS or BLOCKS. From
now on, we will refer to these as
SECTORS. Sectors can be thought of
as 'buckets' of information which ride
along the disk on their respective
TRACKS. Each track contains a certain
number of 'buckets' or SECTORS of
information. These numbers are as
follows:
TOTAL
# of
TRACK NUMBER SECTOR RANGE SECTORS
{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
1 to 17 0 to 20 21
18 to 24 0 to 18 19
25 to 30 0 to 17 18
31 to 35 0 to 16 17
We can see that as the TRACK number
goes up, there are fewer SECTORS or
'buckets' available for that TRACK.
This is because the higher numbered
tracks lie toward the center of the
disk. Because of this, the physical
size of the track is smaller,
therefore the amount of data which
can be stored is less. Thus, the
number of SECTORS, or 'buckets' is
less.
Now where does that get us?? Well
to use RANDOM ACCESS, all of this is
very important!
On a single disk, there are 664
SECTORS free to use for data and/or
programs. By using RANDOM ACCESS,
you can 'tap into' all of this
storage.
Now on to the REAL STUFF!!
To use RANDOM ACCESS, you must have
two files open - the Command/Error
channel and a channel to send the
DATA through. To open a channel for
DATA transfer the pound sign '#' is
used:
10 OPEN15,8,1 : rem command/error
20 OPEN2,8,2,"#": rem DATA buffer
Now once you have both of these
channels open, I bet you want to send
DATA through them. Well to do this
you first have to 'fill up' your
DATA buffer with the information you
want to write to the disk. This is
done with the PRINT# statement. For
example:
10 OPEN15,8,15 : rem error/comm
20 OPEN2,8,2,"#" : rem DATA buffer
30 :
40 FOR X = 1 to 10
50 PRINT#2,"THIS IS DATA"
60 NEXT X
This small program segment OPEN's
the two channels necessary and then
PRINT's the string 'THIS IS DATA'
to the DATA buffer ten times. Now
none of what we have done yet has
actually WRITTEN anything to the
disk. Before we can do this, we must
'find' a place to 'put' it. This is
done with the BLOCK-ALLOCATE command.
The B-A command checks to see if you
you can put your data where you told
your disk-drive to put it. If after
reading the error channel, you come up
with an ERROR #65 - NO BLOCK, then
you can't put your data there!! You
have to find a different place to put
it. Well, this is where your C-64
really helps you out. When you get
that ERROR #65, your Commodore is also
telling you another place to put your
data. When you read the Error channel
you usually INPUT four different
variables. The last two tell you the
next available TRACK and SECTOR. So,
just by resetting your TRACK and
SECTOR numbers to these two values,
you can attempt to put your DATA in
the next available place.
------- continued in PART 16 ---------